.\"     Title: IPSEC_RANGETOSUBNET
.\"    Author: 
.\" Generator: DocBook XSL Stylesheets v1.73.2 <http://docbook.sf.net/>
.\"      Date: 11/14/2008
.\"    Manual: 8 Sept 2000
.\"    Source: 8 Sept 2000
.\"
.TH "IPSEC_RANGETOSUBNET" "3" "11/14/2008" "8 Sept 2000" "8 Sept 2000"
.\" disable hyphenation
.nh
.\" disable justification (adjust text to left margin only)
.ad l
.SH "NAME"
ipsec_rangetosubnet \- convert address range to subnet
.SH "SYNOPSIS"
.sp
.ft B
.nf
#include <freeswan\.h>

.fi
.ft
.HP 26
.BI "const char *rangetosubnet(const\ ip_address\ *\ " "start" ", const\ ip_address\ *\ " "stop" ", ip_subnet\ *\ " "dst" ");"
.SH "DESCRIPTION"
.PP
\fIRangetosubnet\fR
accepts two IP addresses which define an address range, from
\fIstart\fR
to
\fIstop\fR
inclusive, and converts this to a subnet if possible\. The addresses must both be IPv4 or both be IPv6, and the address family of the resulting subnet is the same\.
.PP
\fIRangetosubnet\fR
returns NULL for success and a pointer to a string\-literal error message for failure; see DIAGNOSTICS\.
.SH "SEE ALSO"
.PP
\fBipsec_initsubnet\fR(3),
\fBipsec_ttosubnet\fR(3)
.SH "DIAGNOSTICS"
.PP
Fatal errors in
\fBrangetosubnet\fR
are: mixed address families; unknown address family;
\fIstart\fR
and
\fIstop\fR
do not define a subnet\.
.SH "HISTORY"
.PP
Written for the FreeS/WAN project by Henry Spencer\.
.SH "BUGS"
.PP
The restriction of error reports to literal strings (so that callers don\'t need to worry about freeing them or copying them) does limit the precision of error reporting\.
.PP
The error\-reporting convention lends itself to slightly obscure code, because many readers will not think of NULL as signifying success\. A good way to make it clearer is to write something like:
.sp
.RS 4
.nf
\fBconst char *error;\fR

\fBerror = rangetosubnet( /* \.\.\. */ );\fR
\fBif (error != NULL) {\fR
\fB        /* something went wrong */\fR
.fi
.RE
.sp
